#ifndef CONFIGUREDIALOG_H
#define CONFIGUREDIALOG_H

#include <QDialog>
#include <QSettings>
#include <QShowEvent>
#include <QAbstractButton>
#include <QStandardItemModel>
#include <../core/cwall.core_global.h>
#include <QSqlDatabase>

namespace Ui {
class ConfigureDialog;
}

class ConfigureDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ConfigureDialog(QSettings *set = 0, QWidget *parent = 0);
    ~ConfigureDialog();
    void mainConnection(QString& host, QString& base, QString& user, QString& passwd);


private slots:
    void updateData();
    void commitData();
    void on_buttonBox_clicked(QAbstractButton *button);
    void on_actionAdd_database_triggered();
    void on_actionDelete_database_triggered();
    void modelIndexChange(QModelIndex index);
    void updateConnettionsName();
    void on_lineEditHost_textEdited(const QString &arg1);
    void on_lineEditDBase_textEdited(const QString &arg1);
    void on_lineEditUser_textEdited(const QString &arg1);
    void on_lineEditPasswd_textEdited(const QString &arg1);
    void on_actionDatabaseSelect_for_use_triggered();
    void on_pushButtonTestConnection_clicked();
    void on_pushButtonBuildDatabase_clicked();
    void on_lineEditPluginsPath_editingFinished();
    void on_toolButtonSetPluginPath_clicked();
    void on_actionPluginReload_plugins_triggered();
    void on_actionPluginDatabase_rebuild_triggered();
    void on_actionPluginSwitch_state_triggered();

private:
    void showEvent(QShowEvent *);
    bool buildDatabase();
    void dicconnect();

    Ui::ConfigureDialog *ui;
    QSettings *settings;
    QStandardItemModel *modelConnections;
    QStandardItemModel *modelPlugin;
    QSqlDatabase db;
    QStringList createDb;

signals:
    void cfgUpdate();
};

#endif // CONFIGUREDIALOG_H
